package cn.jinjimi.app.custom.entity;

import cn.jinjimi.base.preference.PreferenceManager;
import cn.jinjimi.app.AccountManager;
import cn.jinjimi.app.bean.SharePrefKeys;

/**
 * Created by Roy
 * Date: 17/1/9
 */

public class CustomCount {
    // 客户线索数
    public int clueCount;
    // 签单客户数
    public int contractCount;
    // 准客户数
    public int potentialCount;
    // 最近跟进客户数
    public int recentCount;

    public CustomCount() {

    }

    public CustomCount(int clueCount, int contractCount, int potentialCount, int recentCount) {
        this.clueCount = clueCount;
        this.contractCount = contractCount;
        this.potentialCount = potentialCount;
        this.recentCount = recentCount;
    }

    public static CustomCount getCacheCustomCount() {
        CustomCount customCount = new CustomCount();

        customCount.clueCount = PreferenceManager.getIntData(SharePrefKeys.PREF_CUSTOM_CLUE_COUNT + AccountManager.getInstance().getAccount().ssoid);
        customCount.contractCount = PreferenceManager.getIntData(SharePrefKeys.PREF_CUSTOM_CONTRACT_COUNT + AccountManager.getInstance().getAccount().ssoid);
        customCount.potentialCount = PreferenceManager.getIntData(SharePrefKeys.PREF_CUSTOM_POTENTIAL_COUNT + AccountManager.getInstance().getAccount().ssoid);
        customCount.recentCount = PreferenceManager.getIntData(SharePrefKeys.PREF_CUSTOM_RECENT_COUNT + AccountManager.getInstance().getAccount().ssoid);

        return customCount;
    }

    public void setCustomCount(CustomCount count) {
        this.clueCount = count.clueCount;
        PreferenceManager.setData(SharePrefKeys.PREF_CUSTOM_CLUE_COUNT + AccountManager.getInstance().getAccount().ssoid, clueCount);

        this.contractCount = count.contractCount;
        PreferenceManager.setData(SharePrefKeys.PREF_CUSTOM_CONTRACT_COUNT + AccountManager.getInstance().getAccount().ssoid, contractCount);

        this.potentialCount = count.potentialCount;
        PreferenceManager.setData(SharePrefKeys.PREF_CUSTOM_POTENTIAL_COUNT + AccountManager.getInstance().getAccount().ssoid, potentialCount);

        this.recentCount = count.recentCount;
        PreferenceManager.setData(SharePrefKeys.PREF_CUSTOM_RECENT_COUNT + AccountManager.getInstance().getAccount().ssoid, recentCount);
    }

}